package com.work.demo.serialized;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class SerializeDemo {
 
	public static void main(String[] args) {
		Employee e = new Employee();
		e.setLongId(20L);
		try {
			FileOutputStream fileOut = new FileOutputStream("D:\\employee.ser");
			// 创建ObjectOutputStream对象
			ObjectOutputStream out = new ObjectOutputStream(fileOut);
			out.writeObject(e); // 序列化对象e，写入磁盘
			out.close();  
			fileOut.close();
			System.out.println("Serialized data is saved successfully!");
		} catch (IOException i) {
			i.printStackTrace();
		}
	}
}